Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of union! #42

Merged
merged 2 commits into from
May 3, 2024
Merged

Get rid of union! #42

merged 2 commits into from
May 3, 2024

Conversation

gdalle
Copy link
Collaborator

@gdalle gdalle commented May 3, 2024

Modify promote_order and distributive_merge to use reduce

@gdalle gdalle linked an issue May 3, 2024 that may be closed by this pull request
@adrhill
Copy link
Owner

adrhill commented May 3, 2024

Can you run a before-and-after benchmark on the Brusselator to make sure we don't lose performance on BitSet?

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.10%. Comparing base (83cb0b0) to head (15b0cba).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #42      +/-   ##
==========================================
- Coverage   72.30%   72.10%   -0.21%     
==========================================
  Files           8        8              
  Lines         278      276       -2     
==========================================
- Hits          201      199       -2     
  Misses         77       77              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gdalle gdalle mentioned this pull request May 3, 2024
@gdalle
Copy link
Collaborator Author

gdalle commented May 3, 2024

Setup code:

using BenchmarkTools
using SparseConnectivityTracer

include("brusselator.jl")

function benchmark_brusselator(N::Integer)
    dims = (N, N, 2)
    A = 1.0
    B = 1.0
    alpha = 1.0
    xyd = fill(1.0, N)
    dx = 1.0
    p = (A, B, alpha, xyd, dx, N)

    u = rand(dims...)
    du = similar(u)
    f!(du, u) = brusselator_2d_loop(du, u, p, nothing)
    return @benchmark jacobian_pattern($f!, $du, $u)
end

## Run Brusselator benchmarks
for N in (6, 24)
    @info "Benchmarking Brusselator of size $N"
    b = benchmark_brusselator(N)
    display(b)
end

On main:

[ Info: Benchmarking Brusselator of size 6
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
 Range (min  max):  51.700 μs    4.742 ms  ┊ GC (min  max): 0.00%  95.55%
 Time  (median):     55.865 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   63.044 μs ± 109.052 μs  ┊ GC (mean ± σ):  7.22% ±  4.22%

   ▁▆██▇▃                                                       
  ▂███████▆▄▄▃▂▃▂▂▂▂▂▂▂▂▂▂▂▁▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▂
  51.7 μs         Histogram: frequency by time         97.4 μs <

 Memory estimate: 108.00 KiB, allocs estimate: 1252.
[ Info: Benchmarking Brusselator of size 24
BenchmarkTools.Trial: 3286 samples with 1 evaluation.
 Range (min  max):  1.086 ms   10.365 ms  ┊ GC (min  max): 0.00%  66.99%
 Time  (median):     1.248 ms               ┊ GC (median):    0.00%
 Time  (mean ± σ):   1.515 ms ± 712.712 μs  ┊ GC (mean ± σ):  7.19% ± 12.84%

  ▃██▆▅▅▄▃▃▁▁▁ ▁                                              ▁
  ██████████████▇▇▇█▇▇▆▇████▆▇▆▆▆▆▆▅▅▅▆▅▅▆▅▃▄▅▆██▇▆▆▅▅▅▅▃▅▅▄▃ █
  1.09 ms      Histogram: log(frequency) by time      4.21 ms <

 Memory estimate: 2.15 MiB, allocs estimate: 23416.

On no_union!:

[ Info: Benchmarking Brusselator of size 6
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
 Range (min  max):  54.363 μs   3.114 ms  ┊ GC (min  max): 0.00%  94.77%
 Time  (median):     62.468 μs              ┊ GC (median):    0.00%
 Time  (mean ± σ):   67.276 μs ± 82.905 μs  ┊ GC (mean ± σ):  5.55% ±  4.46%

     ▁▁▂▃▃▃▄▄▄▅▆▇█▇▆▆▅▄▃▂▂▁▁              ▁                   ▂
  ▅▄██████████████████████████▇▇▇▇▇███████████▇▇▇▇▇▆▆▆▅▆▆▆▆▅▅ █
  54.4 μs      Histogram: log(frequency) by time      84.6 μs <

 Memory estimate: 108.00 KiB, allocs estimate: 1252.
[ Info: Benchmarking Brusselator of size 24
BenchmarkTools.Trial: 3496 samples with 1 evaluation.
 Range (min  max):  1.060 ms   14.582 ms  ┊ GC (min  max): 0.00%  81.11%
 Time  (median):     1.203 ms               ┊ GC (median):    0.00%
 Time  (mean ± σ):   1.424 ms ± 588.615 μs  ┊ GC (mean ± σ):  6.73% ± 12.66%

   ▅█▇▅▄▃▃▃▃▂▂  ▁                                             ▁
  ▆██████████████████▇▇▇▇▆▇▆▆▆▆▇▇▇▆██▇▇▅▅▆█████▆▇▆▄▅▆▇▅▅▁▁▄▄▄ █
  1.06 ms      Histogram: log(frequency) by time      3.58 ms <

 Memory estimate: 2.15 MiB, allocs estimate: 23416.

@gdalle
Copy link
Collaborator Author

gdalle commented May 3, 2024

No obvious changes

@gdalle
Copy link
Collaborator Author

gdalle commented May 3, 2024

Wait don't merge yet

@adrhill adrhill merged commit ae7199d into main May 3, 2024
2 checks passed
@gdalle gdalle deleted the gd/no_union! branch May 3, 2024 16:18
gdalle added a commit that referenced this pull request May 3, 2024
@gdalle gdalle mentioned this pull request May 3, 2024
@adrhill
Copy link
Owner

adrhill commented May 3, 2024

Reopened as #44.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get rid of union! and push!
3 participants